from src.GameConfig import *


class FrameImageUtil:

    def __init__(self, images):
        self.playIndex = 0
        self.images = images

    def setImages(self, images):
        self.images = images

    def step(self, step):
        # 每隔5帧切换图片
        if not (step % GIF_PLAY_STEP):
            self.playIndex += 1
            if self.playIndex > len(self.images) - 1:
                self.playIndex = 0
                return True  # 播放完一轮动画了
            return False

    def onDraw(self, canvas, rect):
        canvas.blit(self.images[self.playIndex], rect)
